import math

class Point3D:
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

    def translate(self, dx, dy, dz):
        self.x += dx
        self.y += dy
        self.z += dz

# 旋转变换
    def rotate(self, angle, rotation_matrix):
        new_x = (rotation_matrix[0][0] * self.x +
                  rotation_matrix[0][1] * self.y +
                  rotation_matrix[0][2] * self.z)

        new_y = (rotation_matrix[1][0] * self.x +
                  rotation_matrix[1][1] * self.y +
                  rotation_matrix[1][2] * self.z)

        new_z = (rotation_matrix[2][0] * self.x +
                  rotation_matrix[2][1] * self.y +
                  rotation_matrix[2][2] * self.z)

        self.x = new_x
        self.y = new_y
        self.z = new_z

    def display(self):
        print(f"Point3D:({self.x}, {self.y}, {self.z})")

def rotation_matrix_x(angle):
    angle_rad = math.radians(angle)
    return [
        [1, 0, 0],
        [0, math.cos(angle_rad), -math.sin(angle_rad)],
        [0, math.sin(angle_rad), math.cos(angle_rad)]
    ]

def rotation_matrix_y(angle):
    angle_rad = math.radians(angle)
    return [
        [math.cos(angle_rad), 0, math.sin(angle_rad)],
        [0, 1, 0],
        [-math.sin(angle_rad), 0, math.cos(angle_rad)]
    ]
def rotation_matrix_z(angle):
    angle_rad = math.radians(angle)
    return [
        [math.cos(angle_rad), -math.sin(angle_rad), 0],
        [math.sin(angle_rad), math.cos(angle_rad), 0],
        [0, 0, 1]
    ]

if __name__ == "__main__":
    x, y, z = map(float, input("请输入三维坐标 (x, y, z): ").split(","))
    init_point = Point3D(x, y, z)
    point = Point3D(x,y,z)

    # 平移
    dx, dy, dz = map(float, input("请输入平移量 (dx, dy, dz): ").split(","))
    point.translate(dx, dy, dz)

    # 旋转
    angle_x = float(input("请输入绕 X 轴旋转的角度: "))
    point.rotate(angle_x, rotation_matrix_x(angle_x))
    angle_y = float(input("请输入绕 Y 轴旋转的角度: "))
    point.rotate(angle_y, rotation_matrix_y(angle_y))
    angle_z = float(input("请输入绕 Z 轴旋转的角度: "))
    point.rotate(angle_z, rotation_matrix_z(angle_z))

    # 输出
    print("原始坐标: ")
    init_point.display()
    print("坐标转换后坐标")
    point.display()